package tester;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import comunicacao.ReceiveMessageInterface;

/**
 * classe que simula um cliente da base de dados
 * 
 * @author Leonardo Lino Nº45340
 * @author Diogo Pires Nº40351
 */
public class TestClient {
	static public void main(String args[]) {
		ReceiveMessageInterface rmiServer;
		Registry registry;
		String serverAddress = args[0];
		String serverPort = args[1];

		System.out.println("sending request to " + serverAddress + ":"
				+ serverPort);
		try {
			registry = LocateRegistry.getRegistry(serverAddress, (new Integer(
					serverPort)).intValue());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServer"));
			/*System.out.println(rmiServer.falha());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServertemp"));			
			System.out.println(rmiServer.restart());

			rmiServer = (ReceiveMessageInterface) (registry.lookup("dbServer"));
*/
			rmiServer.getTheater("teatro2");
			System.out.println(rmiServer.reserveSeat("teatro2", 5, 25258,"1315"));
			
/*			Teatro teatro = rmiServer.getTheater("teatro1");
			if (teatro != null)
				System.out.println("ID: " + teatro.id + "\n"+"com nome: "
						+ teatro.nome);
*/
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}
}
